

library(foreign)


# ======================================================================================
# =                        Figure 5                                                    =
# ======================================================================================

dat <- read.csv("figure5_data.csv")

postscript(file="Figure5.eps", pointsize=10, width=6.4, height=3,	
	horizontal = FALSE, onefile = FALSE, paper = "special")

layout(matrix(c(2,1),1,2), widths = c(2.7, 3.3)) 
par(mar=c(3, 2, 3, 1.5))


#########Intercepts##############

i1.coef <- dat$coef1; i1.se <- dat$se1;
i2.coef <- dat$coef2; i2.se <- dat$se2;
i3.coef <- dat$coef3; i3.se <- dat$se3;
i4.coef <- dat$coef4; i4.se <- dat$se4;

adjust1 <- .08
adjust2 <- .05

var.names <-c("Health", "Unemployment", "Pensions")
x.axis <- 1:length(var.names)

plot(x.axis, i1.coef, type="n",axes=F, xlab = "", ylab = "", pch = 19, cex = 1.3,
      ylim = c(-8.5,4), xlim = c(min(x.axis-adjust1-.2), max(x.axis+adjust1+.2)),main="Thresholds", 		
		cex.main=1)
axis(2,at=seq(-8,4),cex.axis = 1)
axis(1, at = x.axis, label = var.names, las = 1, tick = T, cex.axis =1)
abline(v = x.axis, lty = 2, lwd = 1, col = "grey")
abline(h = c(-8,-6,-4,-2,2,4), lty = 2, lwd = 1, col = "grey")
abline(h=0, lty = 2, col = "red")
points(x.axis + adjust1*-1,i1.coef, pch = 19, cex = 1.2, col = "black")
segments(x.axis + adjust1*-1, i1.coef-2*i1.se, x.axis + adjust1*-1, i1.coef+2*i1.se,lwd=2)
points(x.axis + adjust2*-1,i2.coef, pch = 19, cex = 1.2, col = "black")
segments(x.axis + adjust2*-1, i2.coef-2*i2.se, x.axis+adjust2*-1, i2.coef+2*i2.se,lwd=2)
points(x.axis + adjust2*1,i3.coef, pch = 19, cex = 1.2, col = "black")
segments(x.axis + adjust2*1, i3.coef-2*i3.se, x.axis+adjust2*1, i3.coef+2*i3.se,lwd=2)
points(x.axis + adjust1*1,i4.coef, pch = 19, cex = 1.2, col = "black")
segments(x.axis+adjust1*1, i4.coef-2*i4.se, x.axis+adjust1*1, i4.coef+2*i4.se,lwd=2)

text(1.1,i1.coef[1],expression(tau[11]),cex=1.1)
text(2.1,i1.coef[2],expression(tau[21]) ,cex=1.1)
text(3.1,i1.coef[3],expression(tau[31]) ,cex=1.1)

text(1.12,i2.coef[1],expression(tau[12]) ,cex=1.1)
text(2.12,i2.coef[2],expression(tau[22]) ,cex=1.1)
text(3.1,i2.coef[3],expression(tau[32]) ,cex=1.1)

text(1.2,i3.coef[1],expression(tau[13]) ,cex=1.1)
text(2.2,i3.coef[2],expression(tau[23]) ,cex=1.1)
text(3.2,i3.coef[3],expression(tau[33]) ,cex=1.1)

text(1.25,i4.coef[1],expression(tau[14]) ,cex=1.1)
text(2.25,i4.coef[2],expression(tau[24]) ,cex=1.1)
text(3.25,i4.coef[3],expression(tau[34]) ,cex=1.1)


############ Loadings #############################

s.coef <- dat$coef
s.se <- dat$se
var.names <-c("Health", "Unemployment", "Pensions")
x.axis <- 1:length(var.names)

plot(x.axis,s.coef, type="n",axes=F, xlab = "", ylab = "", pch = 19, cex = 1.3,
      ylim = c(0.5,2.5), xlim = c(min(x.axis-.12), max(x.axis+.25)),main="Loadings", cex.main=1)
axis(2,at=seq(0.5,2.5 ,by=.5),cex.axis = 1)
axis(1, at = x.axis, label = var.names, las = 1, tick = T, cex.axis =1)
abline(v = x.axis, lty = 2, lwd = 1, col = "grey")
abline(h = c(0,1,2,3), lty = 2, lwd = 1, col = "grey")
points(x.axis,s.coef, pch = 19, cex = 1.2, col = "black")
segments(x.axis, s.coef-1.96*s.se, x.axis, s.coef+1.96*s.se,lwd=2)

text(1.2,s.coef[1]-.1,expression(lambda[1]^(1)),cex=1.1)
text(2.2,s.coef[2]-.1,expression(lambda[2]^(1)) ,cex=1.1)
text(3.2,s.coef[3]-.1,expression(lambda[3]^(1)) ,cex=1.1)

dev.off()


